﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json;
using System.Data;
using DataAccess;
using Com.Alipay;

namespace AnTeWei
{
    public class Common
    {
        

        public static string APPID = "wx06380c9963e21baa";
        public static string AppSecret = "ebf6da2a6b38e2ab8f80c3795aa76e3";

        /// <summary>
        /// 信息返回
        /// </summary>
        /// <param name="strError">返回值：-1：失败;0：成功</param>
        /// <param name="strMessage">返回信息</param>
        /// <param name="strStep">日志步骤</param>
        public static JObject Return(string strError, string strMessage, string strStep)
        {
            JObject jObj = new JObject();
            jObj["error"] = strError;
            jObj["message"] = strMessage;

            DBLog.WriteDBLog(strStep, "", JsonConvert.SerializeObject(jObj));
            return jObj;
        }

        ///// <summary>
        ///// 成功信息返回
        ///// </summary>
        ///// <param name="strError">返回值：-1：失败;0：成功</param>
        ///// <param name="strMessage">返回信息</param>
        ///// <param name="strStep">日志步骤</param>
        //public static JObject TrueReturn(string strError, string strMessage, string strStep)
        //{
        //    JObject jObj = new JObject();
        //    jObj["error"] = strError;
        //    jObj["message"] = strMessage;

        //    DBLog.WriteDBLog(strStep, "", JsonConvert.SerializeObject(jObj));
        //    return jObj;
        //}


        public static string GetNewId()
        {
            string strNewId="";
            string strSql = "select newid() id";

            strSql = string.Format(strSql);
            
            DataTable dtResult=new DALTransaction().GetDataTableBySQLText(strSql);
            if (dtResult != null || dtResult.Rows.Count > 0)
            {
                strNewId = dtResult.Rows[0]["id"].ToString();
            }
            else
            {
                strNewId = "9999999";
            }
            return strNewId;
        }

    }
}